package com.anjie.powerproject.map.impl;

import com.anjie.powerproject.entity.GraphInfo;
import com.anjie.powerproject.map.GraphMap;
import com.anjie.powerproject.pojo.dto.GraphDTO;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class GraphMapImpl implements GraphMap {

    @Override
    public GraphDTO toDTO(GraphInfo graphInfo) {
        if ( graphInfo == null ) {
            return null;
        }

        GraphDTO graphDTO = new GraphDTO();

        graphDTO.setGraphId( graphInfo.getGraphId() );
        graphDTO.setGraphName( graphInfo.getGraphName() );

        return graphDTO;
    }

    @Override
    public List<GraphDTO> toDTO(List<GraphInfo> graphInfos) {
        if ( graphInfos == null ) {
            return null;
        }

        List<GraphDTO> list = new ArrayList<GraphDTO>( graphInfos.size() );
        for ( GraphInfo graphInfo : graphInfos ) {
            list.add( toDTO( graphInfo ) );
        }

        return list;
    }
}
